﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace BHair.xitong
{
    public partial class frmshujuqingli : Form
    {
        public frmshujuqingli()
        {
            InitializeComponent();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void button1_Click(object sender, EventArgs e)
        {
            string pwd = textBox1.Text;
            string year = DateTime.Today.Year.ToString();
            string mm = DateTime.Today.Month.ToString();
            string dd = DateTime.Today.Day.ToString();
            string yz = dd + mm + year;
            if (pwd == yz)
            {
                if (checkBox1.Checked == true)
                {
                    try
                    {
                        string sql = "DELETE FROM ycxm";//清理预存项目
                        string sql1 = "DELETE FROM 交班表";//清理交班表
                        string sql2 = "DELETE FROM 会员续期";//清理会员续期
                        string sql3 = "DELETE FROM 操作日志";//清理操作日志
                        string sql4 = "DELETE FROM 收入明细";//清理收入明细表
                        string sql5 = "DELETE FROM 计次充值";//清理计次充值表
                        string sql6 = "DELETE FROM 销售明细";//清理销售明细表
                        string sql7 = "DELETE FROM 销售表";//清理销售表
                        string sql8 = "DELETE FROM 项目充值明细";//清理项目充值明细表
                        string sql11 = "DELETE FROM kcpd";//清理库存盘点表
                        string sql9 = "DELETE FROM jcxf";//清理几次消费表
                        string sql10 = "DELETE FROM jh";//清理进货表
                        string yewuqingli = sql + ";" + sql2 + ";" + sql3 + ";" + sql4 + ";" + sql5 + ";" + sql6 + ";" + sql7 + ";" + sql8 + ";" + sql9 + ";" + sql10 + ";" + sql1 + ";" + sql11;
                        SqlConnection conn = new SqlConnection(constr);
                        conn.Open();
                        SqlCommand comm = new SqlCommand(yewuqingli, conn);
                        comm.ExecuteNonQuery();
                        MessageBox.Show("ok");
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (checkBox2.Checked == true)
                {
                    try
                    {
                        string sql = "DELETE FROM csmx";
                        string sql1 = "DELETE FROM [BHairDB].[dbo].[deposit]";
                        string sql2 = "DELETE FROM [BHairDB].[dbo].[gys]";
                        string sql3 = "DELETE FROM [BHairDB].[dbo].[employee]";
                        string sql4 = "DELETE FROM [BHairDB].[dbo].[items]";
                        string sql5 = "DELETE FROM [BHairDB].[dbo].[jcxf]";
                        string sql6 = "DELETE FROM [BHairDB].[dbo].[jh]";
                        string sql7 = "DELETE FROM [BHairDB].[dbo].[kcpd]";
                        string sql8 = "DELETE FROM [BHairDB].[dbo].[member]";
                        string sql9 = "DELETE FROM [BHairDB].[dbo].[paydetails]";
                        string sql10 = "DELETE FROM [BHairDB].[dbo].[pays]";
                        string sql11 = "DELETE FROM [BHairDB].[dbo].[post]";
                        string sql12 = "DELETE FROM [BHairDB].[dbo].[ycxm]";
                        string sql13 = "DELETE FROM [BHairDB].[dbo].[操作日志]";
                        string sql14 = "DELETE FROM [BHairDB].[dbo].[会员续期]";
                        string sql15 = "DELETE FROM [BHairDB].[dbo].[计次充值]";
                        string sql16 = "DELETE FROM [BHairDB].[dbo].[交班表]";
                        string sql17 = "DELETE FROM [BHairDB].[dbo].[收入明细]";
                        string sql18 = "DELETE FROM [BHairDB].[dbo].[项目充值明细]";
                        string sql19 = "DELETE FROM [BHairDB].[dbo].[销售表]";
                        string sql20 = "DELETE FROM [BHairDB].[dbo].[销售明细]";
                        string sqlde = sql + ";" + sql1 + ";" + sql2 + ";" + sql3 + ";" + sql4 + ";" + sql5 + ";" + sql6 + ";" + sql7 + ";" + sql8 + ";" + sql9 + ";" + sql10 + ";" + sql11 + ";" + sql12 + ";" + sql13 + ";" + sql14 + ";" + sql15 + ";" + sql16 + ";" + sql17 + ";" + sql18 + ";" + sql19 + ";" + sql20;
                        SqlConnection conn = new SqlConnection(constr);
                        conn.Open();
                        SqlCommand comm = new SqlCommand(sqlde, conn);
                        comm.ExecuteNonQuery();
                        MessageBox.Show("ok");
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("特殊操作密码错误请联系软件提供商咨询");
            }
        }
    }
}
